using System.Runtime.InteropServices;
using Baula.TextGen.ComAndVbeIntegration.ComInterfaces;
using Baula.TextGen.Framework.Tools;

namespace Baula.TextGen.ComAndVbeIntegration
{
    [ComVisible(true)]
    [Guid("07B6795A-88A7-461C-96E3-000F8B33F0D6")]
    [ClassInterface(ClassInterfaceType.None)]
    public class DocumentTemplate : Framework.DocumentTemplate, IDocumentTemplateForCom
    {
        static DocumentTemplate()
        {
            Factory.SetFactory(new FactoryForCom());
        }

        IPartTemplateForCom IDocumentTemplateForCom.GetPartTemplate(string partName)
        {
            if (!PartTemplates.ContainsKey(partName))
            {
                throw new Framework.UnknownPartNameException(partName);
            }
            return (IPartTemplateForCom) PartTemplates[partName];
        }

        IDocumentForCom IDocumentTemplateForCom.CreateDocument()
        {
            return new Document(this);
        }
    }
}